home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
090
/
cmln1085.arc
/
FRACTALS.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1986-02-27
|
2KB
|
90 lines
{$u+ }
program fractals;
{ Modified Greg Turk's fractals program from BYTE, Sept. 1984 }
type complex = record x,y : real end;
var cx, cy, i : integer;
z, lambda : complex;
sc : real;
{ Include here the files needed to interface to GSX }
{$iB:GSXWORK.INC}
{$iB:GSXLINE.INC}
procedure z_times_l;
var tx,ty : real;
begin with z do begin
tx := x; ty := y;
x := tx * lambda.x - ty * lambda.y;
y := tx * lambda.y + ty * lambda.x
end
end;
procedure sqrt_of_z;
var t,s : real;
begin with z do begin
t := y;
s := sqrt(sqr(x) + sqr(y));
y := sqrt((s-x+0.00001)/2.0 );
x := sqrt((s+x+0.00001)/2.0);
if t<0 then x := -x
end
end;
procedure function_of_z;
begin z_times_l;
with z do begin
x := 1.0 - x;
sqrt_of_z;
if random < 0.5 then begin x := -x; y := -y end;
x := 1.0 - x;
x := x/2.0 ; y := y/2.0
end
end;
procedure four_over_l;
var s: real;
begin with lambda do begin
s := sqr(x) + sqr(y);
x := 4.0 * x / s;
y := -4.0 * y / s
end
end;
procedure getvalues;
begin with lambda do begin
write('What is lambda? x,y ');
readln(x,y); writeln(x,y);
four_over_l
end;
write('What is scale? ');
readln(sc); writeln(sc);
sc := 2.0 * cx / sc
end;
procedure plotz;
var point : array[1..4] of integer;
begin point[1] := trunc( sc * (z.x - 0.5) + cx);
point[2] := trunc(cy - sc * z.y);
point[3] := point[1]; point[4] := point[2];
{writeln(point[1],' ',point[2]);}
polyline(2,addr(point))
end;
{********************** main ***********************}
begin cx := 32767 div 2; cy := cx; z.x:=0.50001; z.y:= 0.0;
randomize;
getvalues;
writeln('Enter workstation number (1,2,21)> ');readln(i);
openworkstation(i);
for i:= 1 to 10 do function_of_z;
while not keypressed do begin
function_of_z;
plotz
end;
updatestation;
closestation
end.